var swipes = [];

$('section').on('click', '.swipe-wrap div, a', function(e) {
    e.preventDefault();
    var _tripid = $(this).data('trip-id');
    var _wpid = $(this).data('wp-id');
    if (_tripid && _wpid) {
      btAppSchema.jumpToWaypoint(_tripid, _wpid);
      return;
    }

    var _userid = $(this).data('userid');
    if (_userid) {
        btAppSchema.jumpToUser(_userid);
    }
});

var initSwipe = function () {
    $('.swipe').each(function(i, obj) {
        swipes[i] = new Swipe(obj, {
            // auto: 3000,
            continuous: false,
            callback: function(pos) {
                bullets = $(obj).find('li');
                var j = bullets.length;
                while (j--) {
                    bullets[j].className = ' ';
                }
                bullets[pos].className = 'on';
            }
        });
    });
};

var initRedirectFunc = function () {
    $('#detail').on('click', '#detail-address', function(e) {
        e.preventDefault();
        var _destName = $(this).attr('data-destName');
        var _destId = $(this).attr('data-destId');
        var _destType = $(this).attr('data-destType');
        btAppSchema.jumpToDestinationTab(_destName, _destId, _destType, 'map');
    }).on('click', '#detail-tel', function(e) {
        e.preventDefault();
        var _tel = $(this).find('dd').text();
        window.location.href = 'tel:' + _tel;
    }).on('click', '#detail-website', function(e) {
        e.preventDefault();
        var _url = $(this).find('dd').text();
        btAppSchema.jumpToWebView(_url);
    });
};

initRedirectFunc();
if ( $('body').data('user-agent') != 4 ) {
    initSwipe();
}
btAppSchema.resetHeight(document.body.scrollHeight);
